package model;

import java.util.ArrayList;
/**
 * Write a description of class PersonContainer here.
 * 
 * @author Group 3 
 * @version (a version number or a date)
 */
public class PersonContainer{
    //Fields 
    private ArrayList<Person> persons;
    private static PersonContainer instance;
    
    
    //Constructor
    public PersonContainer(){
        persons=new ArrayList <> ();
    }
    
    //Methods
    public void addPerson(Person p) {
        persons.add(p);
    }
    
    public static PersonContainer getInstance(){
        if (instance == null) {
            instance= new PersonContainer();
        }
        return instance;
    }
    
    public void UpdatePerson(String id, String name, String adress, String phone){
        for(int i=0; i<persons.size(); i++) {
            if(persons.get(i).getID().equals(id)){
                persons.get(i).setName(name);
                persons.get(i).setAddress(adress);
                persons.get(i).setPhone(phone);
            }
        }
    }
    
    public void DeletePerson(Person p){
        persons.remove(p);
    }
}